import { SAVR_USER_INFO, DELETE_USER_INFO } from '../action_types'
import { meshLog, SPRemove, SPGet, SPSet } from '../../config'

let meshList = 1    //修改登录返回值的地方
let token = SPGet('token')
let email = SPGet('email')
let useName = SPGet('useName')
let initState = {
    //meshList: meshList || '',
    token: token || '',
    isLogin: meshList && token ? true : false,
    email: email || '',
    useName: useName || ''
}

export default function test(perState = initState, action) {
    // meshLog('被调用了');
    const { type, date } = action
    let newState
    switch (type) {
        case SAVR_USER_INFO:
            newState = { meshList: date.meshList, token: date.token, isLogin: true, email: date.email, useName: date.useName, }
            return newState
        case DELETE_USER_INFO:
            newState = { meshList: '', token: '', isLogin: false, email: '' }
            return newState
        default:
            return perState
    }

}
